<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>
        医生管理
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="css/main.css" media="all">
    <script type="text/javascript" src="lib/loading/okLoading.js"></script>
    <!--百度编辑器-->
    <script src="ueditor/ueditor.config.js"></script>
    <script src="ueditor/ueditor.all.min.js"></script>
    <script src="ueditor/lang/zh-cn/zh-cn.js"></script>

</head>
<style>

</style>
<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>医生管理</cite></a>
              <a><cite>修改医生信息</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <form class="layui-form layui-form-pane" action="" id="mod">
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <div class="layui-tab-content" >
                <div class="layui-tab-item layui-show">
                    <!--<form class="layui-form layui-form-pane" action="" id="add">-->
                    <input type="hidden" name="id" value="">
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red' >*</span>医生编号
                        </label>
                        <div class="layui-input-block">
                            <input type="text"  id="dc_ID" name="dc_ID" autocomplete="off" placeholder="医生编号"
                                   class="layui-input" required="" lay-verify="required" value="">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red' >*</span>用户名
                        </label>
                        <div class="layui-input-block">
                            <input type="text"  id="userName" name="userName" autocomplete="off" placeholder="用户名"
                                   class="layui-input" required="" lay-verify="required" value="">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" >
                            <span class='x-red' >*</span>密码
                        </label>
                        <div class="layui-input-block">
                            <input type="text" id="password" name="password" autocomplete="off" placeholder="密码"
                                   class="layui-input" required="" lay-verify="required" value="">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>年龄
                        </label>
                        <div class="layui-input-block">
                            <input type="text" id="age" name="age" autocomplete="off" placeholder="年龄"
                                   class="layui-input" lay-verify="required" value="">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>科室
                        </label>
                        <div class="layui-input-block">
                            <input type="text" id="clinic" name="clinic" autocomplete="off" placeholder="科室"
                                   class="layui-input" lay-verify="required" value="">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" >
                            <span class='x-red'>*</span>候诊数
                        </label>
                        <div class="layui-input-block">
                            <input type="text" id="access" name="access" autocomplete="off" placeholder="候诊数"
                                   class="layui-input" lay-verify="required" value="">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>真实姓名
                        </label>
                        <div class="layui-input-block">
                            <input type="text" id="realName" name="realName" autocomplete="off" placeholder="真实姓名"
                                   class="layui-input" lay-verify="required" value="">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <button class="layui-btn" type="submit" lay-filter="mod" lay-submit="">
                            修改
                        </button>
                    </div>
                    <!--</form>-->
                    <div style="height:100px;"></div>
                </div>

            </div>

        </div>

    </form>
</div>
<script src="lib/layui/layui.js" charset="utf-8"></script>
<script src="js/x-layui.js" charset="utf-8"></script>
<script type="text/javascript">
    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    UE.getEditor('content',{initialFrameWidth:700,initialFrameHeight:200,});
</script>
<script>
    layui.use(['element','layer','form'], function(){
        $ = layui.jquery;//jquery
        lement = layui.element();//面包导航
        layer = layui.layer;//弹出层
        form = layui.form();
        okLoading.close($);
        function getArgs( ) {
            var args = new Object( );
            var query = location.search.substring(1);     // Get query string
            var pairs = query.split("&");                 // Break at ampersand
            for(var i = 0; i < pairs.length; i++) {
                var pos = pairs[i].indexOf('=');          // Look for "name=value"
                if (pos == -1) continue;                  // If not found, skip
                var argname = pairs[i].substring(0,pos);  // Extract the name
                var value = pairs[i].substring(pos+1);    // Extract the value
                value = decodeURIComponent(value);        // Decode it, if needed
                args[argname] = value;                    // Store as a property
            }
            return value;                                  // Return the object
        }

        initInfo()

        function initInfo(){
            var a = getArgs()
            // alert(a)
            $.ajax({
                async: true,
                url:"/doctor/findById?dc_ID="+a,
                dataType: 'json',
                // error:function (){ alert(11111)},
                success(res){
                    // alert(res.state)
                    if(res.state === 200) {
                        var data = res.data
                        // alert(data.dc_ID)
                        $("#dc_ID").val(data.dc_ID)
                        $("#userName").empty().val(data.realName)
                        $("#password").empty().val(data.password)
                        $("#age").empty().val(data.age)
                        $("#clinic").empty().val(data.clinic)
                        $("#access").empty().val(data.access)
                        $("#realName").empty().val(data.realName)
                    }
                }
            })
        }


        //监听提交
        form.on('submit(mod)', function (data) {
            var userName = $("input[name='userName']").val();
            var password = $("input[name='password']").val();
            var age = $("input[name='age']").val();
            if (userName === "") {
                layer.msg('用户名不能为空', {icon: 5, time: 2000});
                return false;
            }
            if (password === "") {
                layer.msg('密码不能为空', {icon: 5, time: 2000});
                return false;
            }
            if (age === "") {
                layer.msg('年龄不能为空', {icon: 5, time: 2000});
                return false;
            }
            var form = data.field;
            $.ajax({
                async: false,
                type: "post",
                url: "/doctor/update",
                data: form,
                // dataType: "text",
                error: function () {
                    alert("修改错误")
                },
                success: function (res) {
                    if(res.state === 200) {
                        alert("修改成功，请刷新页面")
                    }
                }
            });
            window.opener=null;
            window.open('','_self');
            window.close();
        });
})

</script>

</body>
</html>